import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *


	
def replyFinished(pReply):
	data = pReply.readAll();
	data = str(data)
	
	found = data.find("Google")
	
	if found == -1:
		page.mainFrame().evaluateJavaScript("alert('Hello!');")
		
		
if __name__ == "__main__":
	app = QApplication(sys.argv)

	web = QWebView()
	#manager = QNetworkAccessManager()
	#manager.connect(manager, SIGNAL("finished(QNetworkReply)"), manager, SLOT("replyFinished(QNetworkReply)"))

	#web.load(QUrl("https://wireless-auth.bgsu.edu/fs/customwebauth/login.html?switch_url=https://wireless-auth.bgsu.edu/login.html&ap_mac=00:25:84:23:af:00&wlan=bgsu&redirect=google.com"))
	#web.load(QUrl("http://google.com"))
	page = web.page()
	
	data = page.networkAccessManager().get(QNetworkRequest(QUrl("http://google.com"))).readAll()
	
	print(data)
	#frame = page.mainFrame()
	#found = page.findText("document")
	
	#url = frame.url()
	#print(url)
	
	#if found == True:
	#page.mainFrame().evaluateJavaScript("alert('Hello!');")
		#page.mainFrame().addToJavaScriptWindowObject("document.getElementsByName('username')[0].value = 'sdurfey';document.getElementsByName('password')[0].value = 'Ted400!'; submitAction();")
		
	web.show()

	sys.exit(app.exec_())
